<template>
  <div>
    <el-dialog
      title="新建岗位"
      :visible.sync="dialogshow"
      :before-close="dialogClose"
      style="display: none"
      :fullscreen="fullscreen"
    >
      <dialog-tools
        v-bind:back="true"
        v-bind:next="true"
        v-bind:goback="true"
        v-bind:prev="true"
        v-bind:screen="true"
        @clickfullscreen="clickfullscreen"
      >
      </dialog-tools>
      <div>
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-row>
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>

            <el-form-item label="岗位编码" prop="leader">
              <el-input v-model="form.code" placeholder="岗位编码" />
            </el-form-item>

            <el-form-item label="显示顺序" prop="orderNum">
              <el-input-number
                v-model="form.order_num"
                placeholder="请输入显示顺序"
                :min="1"
                :max="100"
                controls-position="right"
              />
            </el-form-item>

            <el-form-item label="岗位状态">
              <el-radio-group v-model="form.status">
                <el-radio :label="0">正常</el-radio>
                <el-radio :label="1">停用</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <!-- <el-button @click="resetForm" style="float:left;margin-left:20px;">查看款号详情</el-button> -->
        <el-button @click="resetForm">重置</el-button>
        <el-button @click="dialogClose">取 消</el-button>
        <el-button type="primary" @click="alertopen">确定</el-button>
      </div>
    </el-dialog>
    <!-- <dialog-search-order
      v-bind:dialogshow="dialogSearchOrder"
      @dialog_close="dialogSearchOrder = !dialogSearchOrder"
    ></dialog-search-order> -->
  </div>
</template>
<style scoped>
</style>

<script>
module.exports = {
  methods: {
    dialogAdd() {
      console.log(123);
    },
    dialogClose() {
      this.$emit("dialog_close", 1);
    },
    clickfullscreen() {
      this.fullscreen = !this.fullscreen;
    },
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
    alertopen() {
      this.$confirm("是否继续操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 表单重置
    resetForm() {
      this.form = {
        deptId: null,
        parentId: null,
        ancestors: null,
        deptName: null,
        orderNum: null,
        leader: null,
        phone: null,
        email: null,
        status: 0,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        sort: 1,
      };
      this.resetForm("form");
    },
  },
  props: ["dialogshow"],
  data() {
    return {
      fullscreen: false,
      form: {
        deptId: null,
        parentId: null,
        ancestors: null,
        deptName: null,
        orderNum: null,
        leader: null,
        phone: null,
        email: null,
        status: 0,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        sort: 1,
      },
      rules: {},
      parentIdOptions: [
        {
          label: "柏铖艺术",
          value: 1,
          id: 114,
          children: [
            {
              label: "销售部",
              value: 2,
              id: 115,
            },
            {
              label: "采购部",
              value: 3,
              id: 116,
            },
          ],
        },
      ],
    };
  },
  components: {
    "dialog-tools": "url:../tools/dialog-tools.vue",
    "dialog-search-order": "url:./search-order.vue",
  },
};
</script>
